@echo off
echo Starting Snake Game with GPU acceleration...

REM Set JVM parameters for GPU optimization
set JAVA_OPTS=-Xmx8g -Xms2g
set JAVA_OPTS=%JAVA_OPTS% -Dorg.bytedeco.javacpp.maxbytes=8G
set JAVA_OPTS=%JAVA_OPTS% -Dorg.bytedeco.javacpp.maxphysicalbytes=12G
set JAVA_OPTS=%JAVA_OPTS% -Dorg.nd4j.linalg.factory=org.nd4j.linalg.gpu.CudaNDArrayFactory
set JAVA_OPTS=%JAVA_OPTS% -Dorg.nd4j.linalg.ops=org.nd4j.linalg.gpu.ops.CudaOpExecutioner

echo JVM Options: %JAVA_OPTS%
echo.

REM Check if CUDA is available
nvidia-smi >nul 2>&1
if %errorlevel% neq 0 (
    echo WARNING: nvidia-smi not found. GPU may not be available.
    echo.
) else (
    echo GPU Status:
    nvidia-smi --query-gpu=name,memory.total,memory.used --format=csv,noheader,nounits
    echo.
)

REM Run the application with GPU support
echo Running with GPU acceleration...
java %JAVA_OPTS% -cp "target/classes;target/dependency/*" org.dxy.trigger.SnakeGameWithDQN

REM Alternative: use Maven exec (slower but handles dependencies automatically)
REM mvn exec:java -Dexec.mainClass="org.dxy.trigger.SnakeGameWithDQN"

pause